// JavaScript Document

//Меню

$(document).ready(function() {	
$(".m1").find("img").attr("src","images/hmt.png");
	$(".m1").css("top","-10px");
	
	var nav = $('#menu2'),
    navItems = $('.menu3', nav),
    from = 0,
    to = 0,
    timer;
 
function startEffect(t,f){
    var inc = t > f ? 1 : -1;
    navItems.eq(f)
      .css("top","0px")
      .find('img').attr('src', 'images/hmf.png');
    navItems.eq(f + inc)
      .css("top","-10px")
      .find('img').attr('src', 'images/hmt.png');
    if((f = f + inc) == t ) {
        clearTimeout(timer);
        navItems.removeClass('active');
        navItems.eq(f).addClass('active');
        return false;
    }
    timer = setTimeout(startEffect, 150, t, f);
}
function foo(){ 
    clearTimeout(timer);
    to = $(this).index();
    from = nav.find('.active').index('.menu3');
    return to != from ? startEffect(to,from) : false;
}
 
navItems.mouseenter(foo);	
	
	});
	
	
	//Слайдер
$(document).ready(function() {
			var images = ["images/slide/baner.png", "images/slide/2.jpg", "images/slide/3.jpg", "images/slide/4.jpg", "images/slide/5.jpg"];
			var currentImage = 0;
			$("#img").attr("src", images[currentImage]);
			
			$(".baner_l").click(function() {
				if (currentImage == 0) {
				   currentImage=images.length - 1;
				}
					currentImage--;
					$("#img").fadeToggle("fast");
					$(".baner_ten").fadeToggle("fast");
					setTimeout(function() {
						$("#img").attr("src", images[currentImage]);
					}, 200);
					$("#img").fadeToggle("fast");
					$(".baner_ten").fadeToggle("fast");
			});
			$(".baner_r").click(function() {
				if (currentImage == images.length - 1) {
					currentImage=-1;
				}
					currentImage++;
					$("#img").fadeToggle("fast");
					$(".baner_ten").fadeToggle("fast");
					setTimeout(function() {
						$("#img").attr("src", images[currentImage]);
					}, 200);
					$("#img").fadeToggle("fast");
					$(".baner_ten").fadeToggle("fast");
				
			});
		});	 
	